
package com.sskj.jgxt.impl;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.sskj.jgxt.jd.vo.FileInfo;
import com.sskj.utils.HttpUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "**/sskj/file")
@Api(value = "文件信息", description = "文件信息")
public class WeChartFileServiceImpl {

	protected final Log logger = LogFactory.getLog(WeChartFileServiceImpl.class);

	@Value("${sskj.conf.restUrl}")
	private String restUrl;
	
	@Value("${sskj.conf.gsggUrl}")
	private String gsggUrl;	
	
	
	/***
	 * 文件信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/cawd", method = RequestMethod.GET)
	@ApiOperation(value = "质量整改信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(name = "docId", value = "ID",
			paramType = "query", dataType = "string") })
	public void queryCAPDF(String docId, HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		FileInfo result = new FileInfo();		
		if(!StringUtils.isEmpty(docId))
		{
			
			String ss = 
					HttpUtils.sendGet(
							restUrl + "filecontrol/cawd/" + docId,
					null);
	
			if (ss != null) {
				result = JSONObject.parseObject(ss, FileInfo.class);
			}
	
			if (result.getData() != null) {
				response.getOutputStream().write(result.getData());
			}
		}
	}
	

	/***
	 * 文件信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/zlzgtzswd", method = RequestMethod.GET)
	@ApiOperation(value = "质量整改信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(name = "docId", value = "ID",
			paramType = "query", dataType = "string") })
	public void queryZLZGPDF(String docId, HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		FileInfo result = new FileInfo();		
		if(!StringUtils.isEmpty(docId))
		{
			
			String ss = 
					HttpUtils.sendGet(
							restUrl + "filecontrol/zlzgtzswd/" + docId,
					null);
	
			if (ss != null) {
				result = JSONObject.parseObject(ss, FileInfo.class);
			}
	
			if (result.getData() != null) {
				response.getOutputStream().write(result.getData());
			}
		}
	}

	/***
	 * 文件信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/zljbtgtzswd", method = RequestMethod.GET)
	@ApiOperation(value = "质量局部停工信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(name = "docId", value = "ID",
			paramType = "query", dataType = "string") })
	public void queryZLJBPDF(String docId, HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		FileInfo result = new FileInfo();		
		if(!StringUtils.isEmpty(docId))
		{
			String ss = 
					HttpUtils.sendGet(
					restUrl + "filecontrol/zljbtgtzswd/" + docId,
					null);
	
			if (ss != null) {
				result = JSONObject.parseObject(ss, FileInfo.class);
			}
	
			if (result.getData() != null) {
				response.getOutputStream().write(result.getData());
			}
		}
	}	

	/***
	 * 文件信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/aqzgtzswd", method = RequestMethod.GET)
	@ApiOperation(value = "安全整改信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(name = "docId", value = "ID",
			paramType = "query", dataType = "string") })
	public void queryAQZGPDF(String docId, HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		FileInfo result = new FileInfo();		
		if(!StringUtils.isEmpty(docId))
		{
			String ss = 
					HttpUtils.sendGet(
					restUrl + "filecontrol/aqzgtzswd/" + docId,
					null);
	
			if (ss != null) {
				result = JSONObject.parseObject(ss, FileInfo.class);
			}
	
			if (result.getData() != null) {
				response.getOutputStream().write(result.getData());
			}
		}
	}		
	
	/***
	 * 文件信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/aqjbtzswd", method = RequestMethod.GET)
	@ApiOperation(value = "安全局部停工通知书信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(name = "docId", value = "ID",
			paramType = "query", dataType = "string") })
	public void queryAQJBTGPDF(String docId, HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		FileInfo result = new FileInfo();		
		if(!StringUtils.isEmpty(docId))
		{
			String ss = 
					HttpUtils.sendGet(
					restUrl + "filecontrol/aqjbtgtzswd/" + docId,
					null);
	
			if (ss != null) {
				result = JSONObject.parseObject(ss, FileInfo.class);
			}
	
			if (result.getData() != null) {
				response.getOutputStream().write(result.getData());
			}
		}
	}	
	
	/***
	 * 文件信息
	 * 
	 * @return
	 * @throws IOException
	 */
	@CrossOrigin(origins = "*", maxAge = 3600)
	@RequestMapping(value = "/aqtgtzswd", method = RequestMethod.GET)
	@ApiOperation(value = "安全局部通知书信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(name = "docId", value = "ID",
			paramType = "query", dataType = "string") })
	public void queryAQTGTZSPDF(String docId, HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		FileInfo result = new FileInfo();		
		if(!StringUtils.isEmpty(docId))
		{
			String ss = 
					HttpUtils.sendGet(
					restUrl + "filecontrol/aqtgtzswd/" + docId,
					null);
	
			if (ss != null) {
				result = JSONObject.parseObject(ss, FileInfo.class);
			}
	
			if (result.getData() != null) {
				response.getOutputStream().write(result.getData());
			}
		}
	}			
	
	
}
